home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
245
/
mag3
/
magnify.s
< prev
next >
Wrap
Text File
|
1988-10-10
|
4KB
|
114 lines
adr1 equ a1
adr2 equ a2
des_adr1 equ a4
des_adr2 equ a5
copy_adr equ a6
text
move.l 4(sp),des_adr1 ; The physical screen's address.
move.l 8(sp),adr1 ; The location where the start of the
; GET bitblock is stored.
move.l adr1,adr2 ; Adr1 must be set two bytes ahead
add.l #2,adr2 ; ahead of adr1.
add.l #88,des_adr1 ; The initial offset for the
; destination block.
move.l des_adr1,des_adr2 ; Des_adr2 must also be set
add.l #2,des_adr2 ; two bytes ahead of des_adr1.
; This does the actual work...
move.w #50,d0 ; The number of lines in the GET command.
L0: move.w #3,d1 ; The main idea behind this program is that
L1: move.w #1,d2 ; the horizontal bits are copied four times
L2: move.w #7,d3 ; and then each expanded line is reproduced
L3: cmpi.w #3,d3 ; three more times. This expands the image
; vertically four times also.
bne skip
add.l #2,des_adr1 ; To understand how the horizontal expansion
add.l #2,des_adr2 ; works, a short explanation of how the
; medium resolution screen stores its image
; is necessary.
; In medium-rez only four colors can be displayed (even though all
; 512 colors are available) at one time. Thus each pixel's color
; can be set using only two bits.
skip:
move.l adr1,a0 ; The information for the color of the first
move.l des_adr1,a3 ; sixteen pixels is stored in the first two
jsr Bit_test ; words of the screen's memory. The first pixel's
move.l a3,des_adr1 ; color is determined by the MSB ( Most Significant
; Bit ) of the first word and the MSB of the second
move.l adr2,a0 ; word. Each consecutive bit is determined in a
move.l des_adr2,a3 ; similar fashion until the Least Significant Bit is
jsr Bit_test ; read. This program reads two bits at a time and
move.l a3,des_adr2 ; duplicates each pair four times. An example:
; The initial settings of the pointers
; adr1 and adr2 and des_adr1 and des_adr2.
sub.w #1,d3 ; { adr1 } { adr2 }
dbra d3,L3 ; 1001 1100 1110 0101 0100 0001 1100 0010
; |=== 1st word ===| |=== 2nd word ====|
add.l #1,adr1
add.l #1,adr2 ; {des_adr1} {des_adr2}
; 1111 0000 0000 1111 0000 1111 0000 0000
add.l #2,des_adr1 ; ...etcetra
add.l #2,des_adr2 ; The program keeps track of when the pointers
; need to be moved. Essentially, that is the
dbra d2,L2 ; whole idea.
add.l #2,adr1
add.l #2,adr2
dbra d1,L1
add.l #4,adr1 ; Skip the GET null bytes
add.l #4,adr2
;
move.l des_adr1,copy_adr
add.l #96,des_adr1 ; Set the des_adr1 to the next line
move.w #2,d4 ; Number of copies
L4: sub.l #64,copy_adr ; Set copy_adr to the line's first byte
move.w #63,d5 ; Number of bytes per line
L5: move.b (copy_adr)+,(des_adr1)+ ; Do it
dbra d5,L5 ; 64 times
add.l #96,des_adr1 ; Offset to the next row
dbra d4,L4
move.l des_adr1,des_adr2
add.l #2,des_adr2
dbra d0,L0
rts ; Return to GFA Basic
Bit_test:
move.w d3,d7
sub.w #1,d7
btst d3,(a0)
bne Test2 ; Branch if bit 1=1
btst d7,(a0)
bne Set_01 ; Branch if bit 2=1
Set_00: move.b #$00,(a3)+
rts
Test2:
btst d7,(a0)
bne set_11 ; Branch if bit 2=1
Set_10: move.b #$F0,(a3)+
rts
Set_01: move.b #$0F,(a3)+
rts
Set_11: move.b #$FF,(a3)+
rts
end